﻿using D.Medicalcare.Domain.Entities;
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Read.API.Application.Command.MessageCommand;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Read.API.Controllers
{
    /// <summary>
    /// 消息公告
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    
    public class MessageController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public MessageController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 消息公告显示查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaging<Message>> GetMessage([FromQuery]GetMessageCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
